#include <pybind11/pybind11.h>
#include <VideoCapture/VideoCapture.h>

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

namespace py = pybind11;
PYBIND11_MODULE(GStream, m)
{
    py::class_<Frame>(m, "Frame", py::buffer_protocol())
        .def_buffer([](Frame &f) -> py::buffer_info
                    { return py::buffer_info(
                          f.data,                                                                                /* Pointer to buffer */
                          sizeof(unsigned char),                                                                 /* Size of one scalar */
                          py::format_descriptor<unsigned char>::format(),                                        /* Python struct-style format descriptor */
                          3,                                                                                     /* Number of dimensions */
                          {f.rows, f.cols, 3},                                                                   /* Buffer dimensions */
                          {f.cols * 3 * sizeof(unsigned char), 3 * sizeof(unsigned char), sizeof(unsigned char)} /* Strides (in bytes) for each index */
                      ); });

    py::class_<VideoCapture>(m, "VideoCapture")
        .def(py::init<>())
        .def("open", &VideoCapture::open)
        .def("read", &VideoCapture::read)
        .def("isOpened", &VideoCapture::isOpened);
}
// void pybind_videoc(py::module &m)
// {
//     m.doc() = R"pbdoc(
//             Pybind11 example plugin
//             -----------------------
//             .. currentmodule:: cmake_example
//             .. autosummary::
//                :toctree: _generate
//                add
//                subtract
//         )pbdoc";

//     m.def("add", &add, R"pbdoc(
//             Add two numbers
//             Some other explanation about the add function.
//         )pbdoc");

//     m.def(
//         "subtract", [](int i, int j)
//         { return i - j; },
//         R"pbdoc(
//             Subtract two numbers
//             Some other explanation about the subtract function.
//         )pbdoc");
// }
